<?php 
	//1.导入数据库配置
	require('config.php');

	include 'common.php';

	//2.链接数据库,选择数据库
	$link = mysqli_connect(HOST,USER,PWD) or die('链接数据库失败!');
	mysqli_select_db($link,DBNAME);
	mysqli_set_charset($link,UTF);

	//3.准备sql语句 执行sql语句
	$sql ='select * from news order by id';
	//echo $sql;die;

	$result = mysqli_query($link,$sql);

	if($result){
		$arr = array();
		while ($row = mysqli_fetch_assoc($result)) {

			$arr[] = $row;
			// echo '<pre>';
			// var_dump($arr);	
		
		}

		$s->assign('title','测试文件');

		$s->assign('arr',$arr);
				

	}

	//4.关闭数据库
	mysqli_close($link);

	//解析模板
	$s->display('demo.html');

 ?>

			
